CKEDITOR.dialog.add( 'addImageTmp', function( editor )
    {
        return {
            title : 'Upload file',
            minWidth : 450,
            minHeight : 340,
            contents : [
            {
                id : 'tab1',
                label : '',
                title : '',
                expand:true,
                padding:0,
                elements :
                [ {
                    type : 'html',
                    id : 'content',
                    html :'<div>'+
                    '<iframe src="/admin/upload-pictures/upload-one-files/id/'+$('#id_template').html()+'" style="height: 320px; width: 450px;" id="upload_iframe" scrolling="no" frameborder="0" style="border: 2px solid #ccc;" ></iframe >'
                    +'</div>'
                }]
            }],
            buttons:[CKEDITOR.dialog.okButton, CKEDITOR.dialog.cancelButton],
            onOk : function() {
                // "this" is now a CKEDITOR.dialog object.
                // Accessing dialog elements:
                //var textareaObj = this.getContentElement( 'tab1', 'test111' );
                var imgObj = $("#upload_iframe").contents().find("#realDownFile").attr("rel");
                if(imgObj){
                    
                    var str = '<img src="' + imgObj + '"/>';
                    CKEDITOR.instances.ckeditor.insertHtml(str);
                    $('#email_template').html(CKEDITOR.instances.ckeditor.getData());
                    CKEDITOR.instances['ckeditor'].destroy(true);
                    window.serviseEmail.ckeditorInit();
                    CKEDITOR.instances.ckeditor.setData($('#email_template').html());
                }
            },
            onCancel : function() {
                var imgObj = $("#upload_iframe").contents().find("#realDownFile").attr("rel")
                if(imgObj){
                    $('#email_template').html(CKEDITOR.instances.ckeditor.getData());
                    CKEDITOR.instances['ckeditor'].destroy(true);
                    window.serviseEmail.ckeditorInit();
                    CKEDITOR.instances.ckeditor.setData($('#email_template').html());
                }
            }
        };
    } );